#ifndef RPC_UTIL_H_
#define RPC_UTIL_H_

#include "base/base.h"
#include "include/rpc_def.h"

namespace urpc {
class Connection;

class SenderClosure : public google::protobuf::Closure {
  public:
    SenderClosure(const Message* msg, Connection* conn, uint32 id)
        : msg_(msg), conn_(conn), id_(id) {
    }

    void Run();

  private:
    const Message* msg_;
    Connection* conn_;
    uint32 id_;

    DISALLOW_COPY_AND_ASSIGN(SenderClosure);
};

class AutoRunner {
  public:
    AutoRunner(google::protobuf::Closure* c)
        : closure_(c) {
    }

    ~AutoRunner();

  private:
    google::protobuf::Closure* closure_;

    DISALLOW_COPY_AND_ASSIGN(AutoRunner);
};
}

#endif
